package com.pw.study.structure.queue;

import java.util.Scanner;

/**
 * @Desc: 测试队列
 * @author: future
 * @since: 2022/10/23-22:18
 */
public class QueueClient {
    public static void main(String[] args) {
       //s ArrayQue queue = new ArrayQue(3);
        CircleQueue queue = new CircleQueue(4);
        Scanner sc = new Scanner(System.in);
        boolean loop = true;
        while (loop) {
            System.out.println("s:显示队列");
            System.out.println("a:添加元素");
            System.out.println("g:弹出元素");
            System.out.println("h:获取头元素");
            System.out.println("e:退出");
            char key = sc.next().charAt(0);

            switch (key) {
                case 's':
                    queue.showAll();
                    break;
                case 'a':
                    System.out.println("输入一个元素：");
                    int num = sc.nextInt();
                    queue.addArr(num);
                    break;

                case 'g':
                    int one = queue.getOne();
                    System.out.printf("获取队列元素:%d\n", one);
                    break;
                case 'h':
                    int head = queue.headQueue();
                    System.out.println("获取头元素: " + head);
                    break;
                case 'e':
                    loop = false;
                    sc.close();
                    break;
                default:
                    break;

            }


        }


    }

}
